package com.zzyy.study.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.ChatResponse;
import org.springframework.ai.chat.messages.Media;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.openai.OpenAiChatClient;
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @auther zzyy
 * @create 2024-05-19 15:58
 */
//@RestController
public class MultimodalityController
{
    /*@Resource
    private ChatClient chatClient;

    //http://localhost:24512/ai/multi
    @GetMapping(value = "/ai/multi")
    public Object audioToText(@RequestParam(value = "msg",defaultValue = "描述图片内容") String msg,
                              @RequestParam(value = "imageUrl",defaultValue = "https://oaidalleapiprodscus.blob.core.windows.net/private/org-RNr1cS6XkpMOgAahZ8kbMrOH/user-3ZG4VBUDiorlTw85mFyaouC3/img-4wGnGLtQaah8JVMfcazardLj.png?st=2024-05-19T07%3A06%3A29Z&se=2024-05-19T09%3A06%3A29Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-05-19T05%3A45%3A54Z&ske=2024-05-20T05%3A45%3A54Z&sks=b&skv=2021-08-06&sig=WJ6tkwoIIB7s9AzAZ41EUNFk7A05vcv59FV8JEhQkd8%3D") String imageUrl)
    {
        UserMessage userMessage = new UserMessage(msg, List.of(new Media(MimeTypeUtils.IMAGE_PNG, imageUrl)));

        ChatResponse chatResponse = chatClient.call(new Prompt(userMessage,
                OpenAiChatOptions.builder()
                        .withModel(OpenAiApi.ChatModel.GPT_4_VISION_PREVIEW.getValue())
                        .build()));

        return chatResponse.getResult().getOutput().getContent();
    }*/

}
